// src\main\service\database.ts
import { DataSource } from 'typeorm'
import { BetterSqlite3ConnectionOptions } from 'typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions'

export function initDataBase(option: BetterSqlite3ConnectionOptions) {
  return new Promise<DataSource>((resolve, reject) => {
    const dataSource = new DataSource(option)
    dataSource
      .initialize()
      .then(() => {
        resolve(dataSource)
      })
      .catch((e) => {
        reject(e)
      })
  })
}
// }
